package org.crazyit.activiti_d1._6_AddZipInputStream;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.DeploymentBuilder;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.zip.ZipInputStream;

public class AddZipInputStream {

    public static void main(String[] args) throws FileNotFoundException {

        //1. 创建流程引擎
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

        //2. 得到流程存储服务对象
        RepositoryService repositoryService = engine.getRepositoryService();

        //3. 创建DeploymentBuilder 实例
        DeploymentBuilder builder = repositoryService.createDeployment();

        //4. 获取zip 文件的输入流
        FileInputStream fis = new FileInputStream(new File("c7/target/classes/ZipInputStream.zip"));

        //5. 读取zip 文件, 创建ZipInputStream 对象
        ZipInputStream zi = new ZipInputStream(fis);

        //6. 添加Zip 压缩包资源
        builder.addZipInputStream(zi);

        //7. 执行部署
        builder.deploy();

    }

}
